from Case.python_ui.Common.basepage import Basepage
import time,pytest
import random

from Case.python_ui.PageLocate.admin_notification_template_locator import AdminNotificationTemplateLocator


class AdminNotificationTemplatePage(Basepage):


    #进入AllNotification菜单页面
    def enter_notification_template_page(self):
        time.sleep(2)
        doc = "进入Admin NotificationTemplate菜单页面"
        #此流程需提前进入all notification菜单，该功能由父级函数引用
        for i in range(3):
            try:
                self.wait_elevisble(AdminNotificationTemplateLocator.notification_tempalate_tab,doc)
                self.click_element(AdminNotificationTemplateLocator.notification_tempalate_tab,doc)
                break
            except:
                self.driver.refresh()
                time.sleep(5)
                continue

    #检查公告模板
    def check_announcemennt_template(self):
        self.enter_notification_template_page()
        doc = "检查公告模板"
        time.sleep(2)
        self.wait_elevisble(AdminNotificationTemplateLocator.first_announcement_type,doc)
        name = self.get_element(AdminNotificationTemplateLocator.first_announcement_type,doc).text
        assert name == "Announcement"
        self.wait_elevisble(AdminNotificationTemplateLocator.second_announcement_type, doc)
        name = self.get_element(AdminNotificationTemplateLocator.second_announcement_type, doc).text
        assert name == "Announcement"
        self.wait_elevisble(AdminNotificationTemplateLocator.third_announcement_type, doc)
        name = self.get_element(AdminNotificationTemplateLocator.third_announcement_type, doc).text
        assert name == "Announcement"

    #查看修改公告模板页面
    def view_eidt_announcement_page(self):
        self.enter_notification_template_page()
        doc = "查看修改公告模板页面"
        time.sleep(2)
        self.wait_elevisble(AdminNotificationTemplateLocator.announcement_edit_button, doc)
        self.click_element(AdminNotificationTemplateLocator.announcement_edit_button, doc)
        time.sleep(2)
        self.wait_elevisble(AdminNotificationTemplateLocator.eidt_id,doc)
        temp = self.get_element(AdminNotificationTemplateLocator.eidt_id,doc).get_attribute("class")
        assert "antd4-input antd4-input-disabled" == temp
        self.wait_elevisble(AdminNotificationTemplateLocator.eidt_name, doc)
        self.wait_elevisble(AdminNotificationTemplateLocator.edit_des, doc)
        self.wait_elevisble(AdminNotificationTemplateLocator.background, doc)


    #修改公告模板——本函数返回修改后的模板名称
    #本函数执行完成后，将提留在搜索页面
    def edit_announcemennt_template(self):
        self.enter_notification_template_page()
        doc = "修改公告模板"
        time.sleep(2)
        self.wait_elevisble(AdminNotificationTemplateLocator.first_template_id,doc)
        #获取编辑的模板id
        announcement_id = self.get_element(AdminNotificationTemplateLocator.first_template_id,doc).text
        self.wait_elevisble(AdminNotificationTemplateLocator.announcement_edit_button,doc)
        self.click_element(AdminNotificationTemplateLocator.announcement_edit_button,doc)
        time.sleep(2)
        template_info = {
            "name":"auto_test_announcement_name"+ str(random.randint(1, 1000)),
            "description":"auto_test_announcement_des"+ str(random.randint(1, 1000)),
            "title":"auto_test_announcement_title"+ str(random.randint(1, 1000)),
            "background":"Normal",
            "channel":"all",
            "sms_content":"auto_test_announcement_sms"+ str(random.randint(1, 1000)),
            "email_content":"auto_test_announcement_email"+ str(random.randint(1, 1000)),
            "internal_content":"auto_test_announcement_internal"+ str(random.randint(1, 1000)),
        }
        self.wait_elevisble(AdminNotificationTemplateLocator.eidt_name,doc)
        self.delete_text(AdminNotificationTemplateLocator.eidt_name,doc)
        self.send_keys(AdminNotificationTemplateLocator.eidt_name,template_info["name"],doc)
        self.wait_elevisble(AdminNotificationTemplateLocator.edit_des,doc)
        self.delete_text(AdminNotificationTemplateLocator.edit_des,doc)
        description=template_info["description"]
        self.send_keys(AdminNotificationTemplateLocator.edit_des,description,doc)
        self.wait_elevisble(AdminNotificationTemplateLocator.edit_title, doc)
        self.delete_text(AdminNotificationTemplateLocator.edit_title, doc)
        self.send_keys(AdminNotificationTemplateLocator.edit_title, template_info["title"], doc)
        #编辑Background
        self.wait_elevisble(AdminNotificationTemplateLocator.background,doc)
        self.click_element(AdminNotificationTemplateLocator.background,doc)
        self.wait_elevisble(AdminNotificationTemplateLocator.background_value, doc)
        self.click_element(AdminNotificationTemplateLocator.background_value,doc)
        #编辑sms的内容
        self.wait_elevisble(AdminNotificationTemplateLocator.channel_label_sms,doc)
        label_class = self.get_element(AdminNotificationTemplateLocator.channel_label_sms,doc).get_attribute("class")
        if(label_class == "antd4-checkbox-wrapper antd4-checkbox-wrapper-in-form-item"):
            #sms是未勾选状态
            self.wait_elevisble(AdminNotificationTemplateLocator.channel_label_sms,doc)
            self.click_element(AdminNotificationTemplateLocator.channel_label_sms,doc)
        else:
            #sms是已勾选状态
            self.wait_elevisble(AdminNotificationTemplateLocator.channel_label_sms, doc)
        #print(">>>>>>>>>>>>>>>>>",label_class)
        self.scroll_bar_operation(AdminNotificationTemplateLocator.sms_collapse)
        self.wait_elevisble(AdminNotificationTemplateLocator.sms_collapse,doc)
        self.click_element(AdminNotificationTemplateLocator.sms_collapse,doc)
        time.sleep(2)
        self.scroll_bar_operation(AdminNotificationTemplateLocator.sms_content)
        self.wait_elevisble(AdminNotificationTemplateLocator.sms_content,doc)
        self.delete_text(AdminNotificationTemplateLocator.sms_content,doc)
        self.send_keys(AdminNotificationTemplateLocator.sms_content,template_info["sms_content"],doc)
        self.click_element(AdminNotificationTemplateLocator.sms_collapse, doc)

        #编辑email内容
        self.wait_elevisble(AdminNotificationTemplateLocator.channel_label_email, doc)
        label_class = self.get_element(AdminNotificationTemplateLocator.channel_label_email, doc).get_attribute("class")
        if (label_class == "antd4-checkbox-wrapper antd4-checkbox-wrapper-in-form-item"):
            self.wait_elevisble(AdminNotificationTemplateLocator.channel_label_email, doc)
            self.click_element(AdminNotificationTemplateLocator.channel_label_email, doc)
        else:
            self.wait_elevisble(AdminNotificationTemplateLocator.channel_label_email, doc)
        self.scroll_bar_operation(AdminNotificationTemplateLocator.email_collapse)
        self.wait_elevisble(AdminNotificationTemplateLocator.email_collapse, doc)
        self.click_element(AdminNotificationTemplateLocator.email_collapse, doc)
        time.sleep(2)
        self.scroll_bar_operation(AdminNotificationTemplateLocator.email_content)
        self.wait_elevisble(AdminNotificationTemplateLocator.email_content, doc)
        self.delete_text(AdminNotificationTemplateLocator.email_content, doc)
        self.send_keys(AdminNotificationTemplateLocator.email_content, template_info["email_content"], doc)
        self.click_element(AdminNotificationTemplateLocator.email_collapse, doc)

        #编辑站内信内容
        self.wait_elevisble(AdminNotificationTemplateLocator.channel_label_internal, doc)
        label_class = self.get_element(AdminNotificationTemplateLocator.channel_label_internal, doc).get_attribute("class")
        if (label_class == "antd4-checkbox-wrapper antd4-checkbox-wrapper-in-form-item"):
            self.wait_elevisble(AdminNotificationTemplateLocator.channel_label_internal, doc)
            self.click_element(AdminNotificationTemplateLocator.channel_label_internal, doc)
        else:
            self.wait_elevisble(AdminNotificationTemplateLocator.channel_label_internal, doc)
        self.scroll_bar_operation(AdminNotificationTemplateLocator.internal_collapse)
        self.wait_elevisble(AdminNotificationTemplateLocator.internal_collapse, doc)
        self.click_element(AdminNotificationTemplateLocator.internal_collapse, doc)
        time.sleep(2)
        self.scroll_bar_operation(AdminNotificationTemplateLocator.internal_content)
        self.wait_elevisble(AdminNotificationTemplateLocator.internal_content, doc)
        self.delete_text(AdminNotificationTemplateLocator.internal_content, doc)
        self.send_keys(AdminNotificationTemplateLocator.internal_content, template_info["internal_content"], doc)
        self.click_element(AdminNotificationTemplateLocator.internal_collapse, doc)
        #保存
        self.wait_elevisble(AdminNotificationTemplateLocator.submit_button,doc)
        self.click_element(AdminNotificationTemplateLocator.submit_button,doc)
        time.sleep(2)
        self.search_template_by_full_name(template_info["name"])
        #获取搜索结果的id
        self.wait_elevisble(AdminNotificationTemplateLocator.first_template_id,doc)
        id = self.get_element(AdminNotificationTemplateLocator.first_template_id,doc).text
        text = '预期值:'+announcement_id+' 实际值:'+description
        assert description == id,text
        return template_info


    #完全匹配 搜索模板 公告专用
    def search_template_by_full_name(self,name):
        doc = "完全匹配 搜索模板"
        self.wait_elevisble(AdminNotificationTemplateLocator.search_box,doc)
        self.delete_text(AdminNotificationTemplateLocator.search_box,doc)
        self.send_keys(AdminNotificationTemplateLocator.search_box,name,doc)
        self.wait_elevisble(AdminNotificationTemplateLocator.search_button,doc)
        self.click_element(AdminNotificationTemplateLocator.search_button,doc)
        time.sleep(3)
        self.wait_elevisble(AdminNotificationTemplateLocator.announcement_first_template_name,doc)
        search_result = self.get_element(AdminNotificationTemplateLocator.announcement_first_template_name,doc).text
        assert name == search_result
    # 修 20240422
    # 完全匹配 搜索模板 普通模板专用
    def search_template(self, name):
        doc = "搜索模板"
        self.wait_elevisble(AdminNotificationTemplateLocator.search_box, doc)
        #self.keyboard_event(AdminNotificationTemplateLocator.search_box, doc)
        self.delete_text(AdminNotificationTemplateLocator.search_box, doc)
        self.send_keys(AdminNotificationTemplateLocator.search_box, name, doc)
        self.wait_elevisble(AdminNotificationTemplateLocator.search_button, doc)
        self.click_element(AdminNotificationTemplateLocator.search_button, doc)
        time.sleep(3)
        self.wait_elevisble(AdminNotificationTemplateLocator.frist_template_name, doc)
        search_result = self.get_element(AdminNotificationTemplateLocator.frist_template_name, doc).text
        if name in search_result:
            assert 1 == 1
        else:
            print("搜索失败--name：",name," -- search resule:",search_result)
            assert 0 == 1

    #发送公告到具体的某个用户
    def send_announcement_to_user_email(self,email):
        doc = "发送公告到具体的某个用户"
        self.enter_notification_template_page()
        time.sleep(2)
        #发送公告前，需确认公告已经开启了三个渠道，故先调用编辑公告功能
        template_info = self.edit_announcemennt_template()
        #发送公告，因上个方法已经停留在搜索页面，故而无需再搜索
        self.wait_elevisble(AdminNotificationTemplateLocator.move_action,doc)
        self.move_mouse_to_element(AdminNotificationTemplateLocator.move_action)
        time.sleep(1)
        self.wait_elevisble(AdminNotificationTemplateLocator.announcement_send_button,doc)
        self.click_element(AdminNotificationTemplateLocator.announcement_send_button,doc)
        time.sleep(1)
        self.wait_elevisble(AdminNotificationTemplateLocator.search_specific_user,doc)
        self.click_element(AdminNotificationTemplateLocator.search_specific_user,doc)
        time.sleep(1)
        self.wait_elevisble(AdminNotificationTemplateLocator.select_user,doc)
        self.click_element(AdminNotificationTemplateLocator.select_user, doc)
        self.wait_elevisble(AdminNotificationTemplateLocator.select_user_input, doc)
        temp = self.get_element(AdminNotificationTemplateLocator.select_user_input,doc).get_attribute("class")
        #print(">>>>>>>>>>>>>>>>>>>>>>>>>>",temp)
        self.send_keys(AdminNotificationTemplateLocator.select_user_input,email,doc)
        self.wait_elevisble(AdminNotificationTemplateLocator().get_select_user_value(email),doc)
        self.click_element(AdminNotificationTemplateLocator().get_select_user_value(email),doc)
        self.wait_elevisble(AdminNotificationTemplateLocator.send_ok_button,doc)
        self.click_element(AdminNotificationTemplateLocator.send_ok_button,doc)
        time.sleep(5)
        #进入公告发送记录页面查看是否发送成功
        doc = "进入公告发送记录页面查看是否发送成功"
        self.wait_elevisble(AdminNotificationTemplateLocator.announcement_first_template_name,doc)
        self.click_element(AdminNotificationTemplateLocator.announcement_first_template_name,doc)
        time.sleep(2)
        self.wait_elevisble(AdminNotificationTemplateLocator.send_history_tab,doc)
        self.click_element(AdminNotificationTemplateLocator.send_history_tab,doc)
        time.sleep(3)
        self.wait_elevisble(AdminNotificationTemplateLocator.last_receiver_list,doc)
        self.click_element(AdminNotificationTemplateLocator.last_receiver_list,doc)
        time.sleep(2)
        self.wait_elevisble(AdminNotificationTemplateLocator.last_receiver_email,doc)
        receiver_email = self.get_element(AdminNotificationTemplateLocator.last_receiver_email,doc).text
        assert receiver_email == email
        return template_info



    #发送公告到企业用户
    def send_announcement_to_enterprise(self,type):
        doc = "发送公告到企业用户"
        self.enter_notification_template_page()
        time.sleep(2)
        #发送公告前，需确认公告已经开启了三个渠道，故先调用编辑公告功能
        #template_name = self.edit_announcemennt_template()
        #发送公告，因上个方法已经停留在搜索页面，故而无需再搜索
        self.wait_elevisble(AdminNotificationTemplateLocator.announcement_send_button,doc)
        self.click_element(AdminNotificationTemplateLocator.announcement_send_button,doc)
        time.sleep(1)
        self.wait_elevisble(AdminNotificationTemplateLocator.select_user_type,doc)
        self.click_element(AdminNotificationTemplateLocator.select_user_type,doc)
        self.wait_elevisble(AdminNotificationTemplateLocator.select_user_type_value,doc)
        self.click_element(AdminNotificationTemplateLocator.select_user_type_value,doc)
        self.wait_elevisble(AdminNotificationTemplateLocator.send_ok_button,doc)
        self.click_element(AdminNotificationTemplateLocator.send_ok_button,doc)

    #查看公告详情页
    def view_announcement_detail_page(self):
        self.enter_notification_template_page()
        time.sleep(2)
        doc = "查看公告详情页"
        self.wait_elevisble(AdminNotificationTemplateLocator.announcement_first_template_name, doc)
        announcement_name = self.get_element(AdminNotificationTemplateLocator.announcement_first_template_name,doc).text
        announcement_des = self.get_element(AdminNotificationTemplateLocator.first_template_des,doc).text
        self.click_element(AdminNotificationTemplateLocator.announcement_first_template_name, doc)
        time.sleep(2)
        self.wait_elevisble(AdminNotificationTemplateLocator.announcement_detail_name,doc)
        detail_name = self.get_element(AdminNotificationTemplateLocator.announcement_detail_name,doc).text
        detail_des = self.get_element(AdminNotificationTemplateLocator.announcement_detail_des,doc).text
        assert announcement_name == detail_name,'预期值:'+ announcement_name+ ' 实际值:'+ detail_name
        assert announcement_des == detail_des,'预期值:'+ announcement_des+ ' 实际值:'+ detail_des
        detail_type = self.get_element(AdminNotificationTemplateLocator.announcement_detail_type,doc).text
        assert "Announcement" == detail_type
        self.wait_elevisble(AdminNotificationTemplateLocator.send_history_tab,doc)
        self.click_element(AdminNotificationTemplateLocator.send_history_tab,doc)

    #查看公告编辑历史页
    def view_announcement_edit_history_page(self,template_info):
        self.enter_notification_template_page()
        time.sleep(2)
        doc = "查看公告编辑历史页"
        self.wait_elevisble(AdminNotificationTemplateLocator.announcement_first_template_name, doc)
        announcement_name = template_info["name"]
        announcement_des = template_info["description"]
        self.click_element(AdminNotificationTemplateLocator.announcement_first_template_name, doc)
        time.sleep(2)
        self.wait_elevisble(AdminNotificationTemplateLocator.announcement_template_history_view_detail_button,doc)
        self.click_element(AdminNotificationTemplateLocator.announcement_template_history_view_detail_button,doc)
        time.sleep(3)
        self.wait_elevisble(AdminNotificationTemplateLocator.history_detail_name,doc)
        his_name = self.get_element(AdminNotificationTemplateLocator.history_detail_name,doc).text
        assert announcement_name == his_name
        his_des = self.get_element(AdminNotificationTemplateLocator.history_detail_des, doc).text
        assert announcement_des == his_des
        his_title = self.get_element(AdminNotificationTemplateLocator.history_detail_title,doc).text
        assert his_title == template_info["title"]
        his_type = self.get_element(AdminNotificationTemplateLocator.history_detail_type,doc).text
        assert his_type == "Announcement"
        his_channel = self.get_element(AdminNotificationTemplateLocator.history_detail_channel, doc).text
        assert his_channel == "Internal Messages, SMS, Email"
        his_sms_content = self.get_element(AdminNotificationTemplateLocator.history_detail_SMS_Content,doc).text
        assert his_sms_content == template_info["sms_content"]
        his_email_content = self.get_element(AdminNotificationTemplateLocator.history_detail_email_Content, doc).text
        assert his_email_content == template_info["email_content"]
        his_internal = self.get_element(AdminNotificationTemplateLocator.history_detail_internal_Notification, doc).text
        assert his_internal == template_info["internal_content"]

    # 查看公告发送历史页
    def view_announcement_send_history_page(self, template_info):
        self.enter_notification_template_page()
        time.sleep(2)
        doc = "查看公告发送历史页"

    #查看公告发送页面
    def view_send_announcement_page(self):
        doc = "查看公告发送页面"
        self.enter_notification_template_page()
        time.sleep(2)
        self.wait_elevisble(AdminNotificationTemplateLocator.move_action,doc)
        self.move_mouse_to_element(AdminNotificationTemplateLocator.move_action)
        self.wait_elevisble(AdminNotificationTemplateLocator.announcement_send_button, doc)
        self.click_element(AdminNotificationTemplateLocator.announcement_send_button, doc)
        time.sleep(1)
        self.wait_elevisble(AdminNotificationTemplateLocator.expriation_time,doc)
        expire_time = self.get_element(AdminNotificationTemplateLocator.expriation_time,doc).get_attribute("value")
        expire_time = expire_time.split(" ")
        t = time.time()
        t2 = 7 * 24 * 3600
        t3 = t + t2
        t = time.strftime("%d-%m-%Y", time.localtime(t3))
        assert t == expire_time[0]

    #用户登录页面，查看是否收到公告发送通知
    def user_check_announcement(self,template_info):
        doc = "用户登录页面，查看是否收到公告发送通知"
        self.wait_elevisble(AdminNotificationTemplateLocator.user_announcement_title,doc)
        title = self.get_element(AdminNotificationTemplateLocator.user_announcement_title,doc).text
        content = self.get_element(AdminNotificationTemplateLocator.user_announcement_internal_content, doc).text
        print(">>>>>>>>>>>>title:",title)
        print(">>>>>>>>>>>>content:", content)
        print(">>>>>>>>>>>>title2:", template_info["title"])
        print(">>>>>>>>>>>>content2:", template_info["internal_content"])
        assert title == template_info["title"]
        assert content == template_info["internal_content"]

    #检查template页面
    def check_template_view(self):
        self.enter_notification_template_page()
        doc = "检查template菜单"
        # self.wait_elevisble(AdminNotificationTemplateLocator.template_id,doc)
        # id = self.get_element(AdminNotificationTemplateLocator.template_id,doc).text
        # assert id == "ID"
        name = self.get_element(AdminNotificationTemplateLocator.template_name,doc).text
        assert name == "Name"
        des = self.get_element(AdminNotificationTemplateLocator.template_des,doc).text
        assert des == "Description"
        type = self.get_element(AdminNotificationTemplateLocator.template_notification_type,doc).text
        assert type == "Notification Type"
        create_time = self.get_element(AdminNotificationTemplateLocator.template_create_time,doc).text
        assert create_time == "Creation Time (UTC+08:00)"

    # 刷新template
    def refresh_template_page(self):
        self.enter_notification_template_page()
        doc = "刷新template菜单页面"
        self.wait_elevisble(AdminNotificationTemplateLocator.refresh_button,doc)
        self.click_element(AdminNotificationTemplateLocator.refresh_button,doc)
        self.wait_elevisble(AdminNotificationTemplateLocator.total_count, doc)
        total = self.get_element(AdminNotificationTemplateLocator.total_count, doc).text
        self.wait_elevisble(AdminNotificationTemplateLocator.refresh_button, doc)
        self.click_element(AdminNotificationTemplateLocator.refresh_button, doc)
        time.sleep(2)
        total_new = self.get_element(AdminNotificationTemplateLocator.total_count, doc).text
        assert total == total_new

    #Edit页面检查
    def check_template_edit_page(self,name):
        self.enter_notification_template_page()
        doc = "Edit页面检查"
        self.search_template(name)
        self.wait_elevisble(AdminNotificationTemplateLocator.announcement_edit_button, doc)
        self.click_element(AdminNotificationTemplateLocator.announcement_edit_button, doc)
        time.sleep(2)
        self.wait_elevisble(AdminNotificationTemplateLocator.edit_des, doc)
        self.wait_elevisble(AdminNotificationTemplateLocator.notification_type, doc)
        self.wait_elevisble(AdminNotificationTemplateLocator.background, doc)
        self.wait_elevisble(AdminNotificationTemplateLocator.channel_label_sms, doc)
        self.wait_elevisble(AdminNotificationTemplateLocator.channel_label_email, doc)
        self.wait_elevisble(AdminNotificationTemplateLocator.channel_label_internal, doc)
        self.wait_elevisble(AdminNotificationTemplateLocator.eidt_name, doc)
        self.delete_text(AdminNotificationTemplateLocator.eidt_name, doc)
        time.sleep(2)
        self.wait_elevisble(AdminNotificationTemplateLocator.edit_name_error,doc)
        name_error = self.get_element(AdminNotificationTemplateLocator.edit_name_error,doc).text
        assert name_error == "Please enter name."
        self.wait_elevisble(AdminNotificationTemplateLocator.edit_title,doc)
        self.delete_text(AdminNotificationTemplateLocator.edit_title, doc)
        time.sleep(2)
        self.wait_elevisble(AdminNotificationTemplateLocator.edit_title_error, doc)
        title_error = self.get_element(AdminNotificationTemplateLocator.edit_title_error, doc).text
        assert title_error == "Please enter notification title."
        self.wait_elevisble(AdminNotificationTemplateLocator.eidt_id,doc)
        id_class = self.get_element(AdminNotificationTemplateLocator.eidt_id,doc).get_attribute("class")
        assert id_class == "antd4-input antd4-input-disabled"
    # 修 20240422
    def admin_edit_template(self):
        self.enter_notification_template_page()
        doc = "管理员编辑通知模板"
        des = "When the user first-time sign in on this browser,which will trigger the multi-factor authentication.(Edit)"
        content = "Dear User, Please use the six-digit code ${verificationCode}."
        self.search_template("Enterprise End-user Login Email OTP")
        self.wait_elevisble(AdminNotificationTemplateLocator.announcement_edit_button, doc)
        self.click_element(AdminNotificationTemplateLocator.announcement_edit_button, doc)
        time.sleep(2)
        self.wait_elevisble(AdminNotificationTemplateLocator.edit_des,doc)
        #self.keyboard_event(AdminNotificationTemplateLocator.edit_des,doc)
        self.delete_text(AdminNotificationTemplateLocator.edit_des,doc)
        self.send_keys(AdminNotificationTemplateLocator.edit_des,des,doc)
        self.wait_elevisble(AdminNotificationTemplateLocator.channel_label_internal,doc)
        label_class = self.get_element(AdminNotificationTemplateLocator.channel_label_internal, doc).get_attribute("class")
        if (label_class == "antd4-checkbox-wrapper antd4-checkbox-wrapper-in-form-item"):
            self.wait_elevisble(AdminNotificationTemplateLocator.channel_label_internal, doc)
            self.click_element(AdminNotificationTemplateLocator.channel_label_internal, doc)
        else:
            self.wait_elevisble(AdminNotificationTemplateLocator.channel_label_internal, doc)
        self.scroll_bar_operation(AdminNotificationTemplateLocator.first_collapse)
        self.wait_elevisble(AdminNotificationTemplateLocator.first_collapse, doc)
        self.click_element(AdminNotificationTemplateLocator.first_collapse, doc)
        time.sleep(2)
        self.scroll_bar_operation(AdminNotificationTemplateLocator.first_content)
        self.wait_elevisble(AdminNotificationTemplateLocator.first_content, doc)
        #self.keyboard_event(AdminNotificationTemplateLocator.first_content, doc)
        self.delete_text(AdminNotificationTemplateLocator.first_content, doc)
        self.send_keys(AdminNotificationTemplateLocator.first_content, content , doc)
        self.click_element(AdminNotificationTemplateLocator.first_collapse, doc)
        # 保存
        self.wait_elevisble(AdminNotificationTemplateLocator.submit_button, doc)
        self.click_element(AdminNotificationTemplateLocator.submit_button, doc)
        time.sleep(4)
        #检查是否保存成功
        self.wait_elevisble(AdminNotificationTemplateLocator.announcement_edit_button,doc)
        self.click_element(AdminNotificationTemplateLocator.announcement_edit_button,doc)
        time.sleep(2)
        self.wait_elevisble(AdminNotificationTemplateLocator.edit_des,doc)
        edit_des = self.get_element(AdminNotificationTemplateLocator.edit_des,doc).text
        assert des == edit_des
        self.wait_elevisble(AdminNotificationTemplateLocator.first_collapse,doc)
        self.click_element(AdminNotificationTemplateLocator.first_collapse, doc)
        self.wait_elevisble(AdminNotificationTemplateLocator.first_content, doc)
        edit_content = self.get_element(AdminNotificationTemplateLocator.first_content,doc).text
        assert content == edit_content


    #当前仅用于”Enterprise End-user Login Email OTP“
    def recover_template(self):
        doc = "复原被编辑过的模板"





